class Solution:
    def rob(self, nums) -> int:
        if len(nums) == 1:
            return nums[0]
        return max(self.robEasy(nums[:-1]), self.robEasy(nums[1:]))

    def robEasy(self, nums):
        if len(nums)==0:
            return 0
        p1 = nums[0]
        p2 = 0
        for i in nums[1:]:
            tmp = max(p1, p2 + i)
            p1, p2 = tmp, p1
        return p1


if __name__ == '__main__':
    so = Solution()
    s = [1]
    r = so.rob(s)
    print(r)
